<template>
  <view class="u-page">
    <div class="header">
      <image
        class="header-bg"
        src="https://ysgapi.yfzxzjysg.top/bg.png"
        mode=""
      />
      <cl-header
        title="教师热度榜"
        :isOccupy="false"
        :transparent="true"
        :isBack="true"
      ></cl-header>
    </div>
    <div class="content">
      <div class="content-header">
        <div>排名</div>
        <div class="name">姓名</div>
        <div>分数</div>
      </div>
      <view class="list-style">
        <view v-for="(item, index) in indexList" :key="index">
          <view class="row">
            <view class="row-index" v-if="index < 3">
              <u--image
                v-if="index == 0"
                :showLoading="true"
                :src="require('@/assets/1.png')"
                width="80rpx"
                height="80rpx"
              ></u--image>
              <u--image
                v-if="index == 1"
                :showLoading="true"
                :src="require('@/assets/2.png')"
                width="80rpx"
                height="80rpx"
              ></u--image>
              <u--image
                v-if="index == 2"
                :showLoading="true"
                :src="require('@/assets/3.png')"
                width="80rpx"
                height="80rpx"
              ></u--image>
            </view>
            <view class="row-index" v-else>{{ index + 1 }}</view>
            <u-avatar size="69rpx" :src="item.img"></u-avatar>
            <div class="name">{{ item.name }}</div>
            <div class="tag" v-if="index == 0">金牌讲师</div>
            <div class="tag" v-if="index == 1">银牌讲师</div>
            <div class="tag" v-if="index == 2">铜牌讲师</div>
            <div class="num">
              {{ item.score }}
            </div>
          </view>
        </view>
      </view>
    </div>
  </view>
</template>

<script>
import { getTeacherRank } from "apis/modules/user";
import { getStorage } from "utils/auth";
export default {
  data() {
    return {
      indexList: [],
    };
  },
  onLoad() {
    this.getList();
  },
  methods: {
    getList() {
      let school_id = getStorage("school_id");
      getTeacherRank({ school_id }).then((res) => {
        this.indexList = res;
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.header {
  box-sizing: border-box;
  padding: 180rpx 40rpx 40rpx;
  box-sizing: border-box;
  position: relative;
  z-index: 1;
  overflow: hidden;
  position: sticky;
  top: 0;
  &::after {
    // content: "欢迎进入      走进艺术宫";
    position: absolute;
    top: 70rpx;
    left: 40rpx;
 width: 110rpx;
    color: #fff;
    font-size: 22rpx;
  }
  .header-bg {
    position: absolute;
    z-index: -1;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
  }
  .searchList {
    display: flex;
    overflow-x: auto;
    align-items: center;
    padding: 20rpx;
    .search-item {
      flex-shrink: 0;
      width: 200rpx;
      height: 85rpx;
      text-align: center;
      line-height: 85rpx;
      color: #fff;
      margin-right: 20rpx;
      font-size: 24rpx;
      border-radius: 18rpx;
      background: rgba(192, 190, 190, 0.35);
      box-shadow: 0rpx 3rpx 6rpx 1rpx rgba(0, 0, 0, 0.16);
    }
  }
}
.u-page {
  background: #eee;
  box-sizing: border-box;
  .content {
    margin: 20rpx;
    border-radius: 20rpx;
    padding: 20rpx;
    background: #fff;
    // height: 70vh;
    box-sizing: border-box;
    overflow: hidden;
    &-header {
      display: flex;
      align-items: center;
      font-size: 30rpx;
      font-weight: bold;
      color: #6e6e6e;
      margin: 40rpx;
      .name {
        flex: 1;
        text-align: left;
        padding-left: 50rpx;
      }
    }
    .row {
      display: flex;
      align-items: center;
      padding: 20rpx;
      &-index {
        width: 86rpx;
        height: 86rpx;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #9c9c9c;
        margin-right: 30rpx;
      }
      .name {
        flex: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        width: 135rpx;
        font-size: 26rpx;
        font-weight: 400;
        color: #9c9c9c;
        padding: 0 20rpx;
      }
      .tag {
        flex-shrink: 0;
        font-size: 30rpx;
        font-weight: 400;
        width: 139rpx;
        height: 44rpx;
        background: #ee4d02;
        border-radius: 18rpx 18rpx 18rpx 18rpx;
        color: #ffffff;
        text-align: center;
      }
      .num {
        flex-shrink: 0;
        font-size: 20rpx;
        font-weight: bold;
        width: 100rpx;
        text-align: center;
      }
    }
  }
}
</style>
<style>
.list-style {
  height: 100% !important;
  overflow: auto;
}
</style>
